import {createStore} from "vuex";

import admin from "./module-admin";
import user from "./module-user";

const state = {
    user_name: "Hydra", 
    list: [
        {name: "红红",sex: "女",age: 18},
        {name: "爱爱",sex: "女",age: 16},
        {name: "小文",sex: "男",age: 16},
        {name: "小强",sex: "",age: 16},

    ]
}

const getters = {
    girlList(state) {
        return state.list.filter(v => v.sex == '女');
    }
}

const mutations = {
    add(state,payload) {
        state.list.push(payload);
    }
}

// 使用创建函数创建vuex对象
export default createStore({
    // state: 状态（需要在系统中要到的数据）
    modules: {
        admin,
        user,
        
    },
    mutations,
    state,
    getters
});